package io.github.xbeeant.eoffice.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author xiaobiao
 */
@Configuration
public class WebStaticsConfiguration implements WebMvcConfigurer {
    @Value("${spring.resources.cache.period:3600}")
    private Integer cachePeriod;

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/", "classpath:/META-INF/static/").setCachePeriod(cachePeriod);
        registry.addResourceHandler("/public/**").addResourceLocations("classpath:/public/", "classpath:/META-INF/public/").setCachePeriod(cachePeriod);
        registry.addResourceHandler("/template/**").addResourceLocations("classpath:/template/", "classpath:/META-INF/template/").setCachePeriod(cachePeriod);
    }
}
